﻿using SpaceNeedle.City6473.Web.Data.Repositories;
using SpaceNeedle.City6473.WebSite.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace SpaceNeedle.City6473.WebSite.Controllers
{
    public class SolicitacaoController : GlobalController
    {
        // GET: Solicitacao
        public ActionResult Index(string id)
        {
            var model = new RequestItemsModel();

            RequestItemRepository repository = new RequestItemRepository();

            model.NewRequestItem = repository.GetById(id);
            
            if (model.NewRequestItem == null)
            {
                return RedirectToAction("Error");
            }

            UserRepository users = new UserRepository();
            model.NewRequestItem.User = users.GetById(model.NewRequestItem.CreatedBy);

            return View(model);
        }
    }
}
